/**
 * Created by dale on 20180726
 */
$(document).ready(function () {
    $('#bt_modal_confirm',parent.document).click(function () {

        var file = document.getElementById("fileExcel").files[0];
        if(!file){
            window.top.xhTop.showError(
                '请选择上传文件'
            );
            return false;
        }
        xhExtra.setBtnLoading($('#bt_modal_confirm',parent.document));
        $('#bt_modal_confirm',parent.document).addClass('disabled');
        var formData = new FormData();
        formData.append('file',document.getElementById("fileExcel").files[0]);
        formData.append('iProductId',$('#iProductId').val());
        $.ajax({
            url:moduleUrl+'testcase/importTestCase',
            type: "POST",
            data: formData,
            contentType: false,
            processData: false,
            success: function (data) {
                window.top.xhTop.showSuccess(
                    data.msg
                );
                window.top.xhTop.getActiveFrame().testCaseList.datagrid('clearSelections');
                window.top.xhTop.getActiveFrame().testCaseList.datagrid('reload');
                window.top.xhTop.closeModal();
            },
            error: function (data) {
                xhExtra.setBtnNormal($('#bt_modal_confirm',parent.document));
                $('#bt_modal_confirm',parent.document).removeClass('disabled');
                window.top.xhTop.showError(
                    data.responseJSON.error,
                    data.responseJSON.msg
                );
            }
        });
    });
    // modalBind.bindClick();
});